﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;

namespace WasaWasa
{
    class UserImageCache
    {
        private Dictionary<string, BitmapImage> profileImageCache;

        private UserImageCache()
        {
            profileImageCache = new Dictionary<string, BitmapImage>();
        }

        public BitmapImage GetProfilePicture(string userId)
        {
            if (!profileImageCache.ContainsKey(userId))
            {
                profileImageCache[userId] = new BitmapImage(
                    new UriBuilder(Uri.UriSchemeHttp, MainWindow.ApiPictureHost, MainWindow.ApiPort, "/user/" + userId + "/profile_img.png.64").Uri);
            }
            return profileImageCache[userId];
        }

        public static UserImageCache Default { get; set; }
        static UserImageCache()
        {
            Default = new UserImageCache();
        }
    }
}
